/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.com.janalise.util;

import java.io.IOException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author boskyn9
 */
public class RemoverStopList {

    private static List<String> stopList;

    public static boolean valido(String texto){
        try {
            if(texto!=null && !texto.isEmpty() && !texto.equals(" ") && texto.length() > 1){
                StopWords stopWord = StopWords.getInstance();
                stopList = stopWord.getStopList();
                return !stopList.contains(texto.toLowerCase());
            }
        } catch (IOException ex) {
            Logger.getLogger(RemoverStopList.class.getName()).log(Level.SEVERE, null, ex);
        }
        return false;
    }

    public static String remover(String texto) {
        try {
            if(texto!=null && !texto.isEmpty()){
               StopWords stopWord = StopWords.getInstance();
               stopList = stopWord.getStopList();
                for (String string : stopList) {
                    texto = texto.replace(" "+string+" ", " ");
                }
            }
        } catch (IOException ex) {
            Logger.getLogger(RemoverStopList.class.getName()).log(Level.SEVERE, null, ex);
        }finally{
            return texto;
        }
    }
}
